package cn.ryh.designpatterndemo.factorypattern.simpleFactory;

import cn.ryh.designpatterndemo.factorypattern.entity.IHuman;

/**
 * @ClassName SimpleHumanFactory
 * @Description 简单工厂模式
 * @Author RaoYH
 * @Date 2019/4/19
 */
public class SimpleHumanFactory {

    public static <T extends IHuman> T createHuman(Class<T> c){
        IHuman human = null;

        try {
            human = (IHuman) Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return (T) human;
    }
}
